import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Solution1078 {
    public String[] findOcurrences(String text, String first, String second) {
        String[] temp=text.split(" ");
        List<String> list=new ArrayList<>();
        for (int i=0;i<temp.length-2;i++){
            if (temp[i].equals(first) && temp[i+1].equals(second)){
                list.add(temp[i+2]);
            }
        }
        String[] ans=new String[list.size()];
        for (int i=0;i<list.size();i++){
            ans[i]=list.get(i);
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(Arrays.toString(new Solution1078().findOcurrences("alice is a good girl she is a good student","a","good")));
    }
}
